/*
 * @Author: your name
 * @Date: 2021-11-15 09:49:59
 * @LastEditTime: 2021-11-15 15:48:29
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \flutter_redux\redux_example\lib\widgets\lists_item_view.dart
 */
import 'package:flutter/material.dart';
// import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux_example/store/state.dart';
import 'package:redux_example/widgets/view_model.dart';

class ListsItemView extends StatelessWidget {
  final ViewModel viewModel;
  const ListsItemView(
    this.viewModel, {
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListView(
      children: viewModel.lists
          .map((Item item) => ListTile(
                title: Text('${item.id}-${item.value}'),
                trailing: IconButton(
                  icon: const Icon(Icons.delete),
                  onPressed: () {
                    viewModel.removeItem(item.id);
                  },
                ),
              ))
          .toList(),
    );
  }
}
